package com.cheer.ba.utils;

import android.os.Environment;
import android.util.Log;

import com.litesuits.common.io.FileUtils;

import org.joda.time.DateTime;

import java.io.File;
import java.io.IOException;

/**
 * Created by JS01 on 2016/7/12.
 */
public class LogUtils {

    public static void writeLog(String content) {
        String path = Environment.getExternalStorageDirectory()
                + File.separator + "logs" +
                File.separator + "sns_login.txt";
        File file = new File(path);
        if (!file.exists()) {
            try {
                if (!file.createNewFile()) {
                    return;
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        String time = "[" + DateTime.now().toString("yyyy-MM-dd-hh:mm:ss") + "]";
        try {
            FileUtils.write(file, time + content + "\n", true);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static final String TAG = "huangqiang---";

    public static boolean isLog = true;

    public static void LogD(String tag, String msg) {
        if (isLog) {
            Log.d(TAG + tag, msg);
        }
    }

    public static void LogE(String tag, String msg) {
        if (isLog) {
            Log.e(TAG + tag, msg);
        }
    }

}
